Skip to content

Improve RangeChip with tagged table#38

Merged
CPerezz merged 5 commits into
privacy-ethereum:masterfrom
han0110:feature/range-chip-with-tagged-table
Sep 9, 2022
Merged

Improve RangeChip with tagged table#38
CPerezz merged 5 commits into
privacy-ethereum:masterfrom
han0110:feature/range-chip-with-tagged-table

Conversation

@han0110

@han0110 han0110 commented Aug 20, 2022

Copy link
Copy Markdown
Contributor

Use tagged table in RangeChip to reduce number of lookup.

Resolves #37

@han0110 han0110 force-pushed the feature/range-chip-with-tagged-table branch from 46eb3f1 to 4505bf1 Compare August 30, 2022 13:35

@CPerezz CPerezz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I just left some suggestions that we might want to adopt. Up to you :)
Feel free to address what you think it's fine to and merge!

Thanks for this great work! 🎉

Comment thread maingate/src/range.rs Outdated
let config = TableConfig {
selector: meta.complex_selector(),
column: meta.lookup_table_column(),
let (s_overflow, tag_overflow) = if has_overflow_limb {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? Just a suggestion to save the creation of a variable that might be avoidable. I say it more for ease of read than performance of course.

Suggested change
let (s_overflow, tag_overflow) = if has_overflow_limb {
let (s_overflow, tag_overflow) = if !overflow_bit_lens.is_empty() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 0ca396e

Comment thread maingate/src/range.rs Outdated
Comment on lines +255 to +272
macro_rules! lookup {
($prefix:literal, $selector:ident, $tag:ident, $bit_lens:ident, [$($value:ident),*]) => {
$(
meta.lookup(concat!($prefix, stringify!($value)), |meta| {
let selector = meta.query_selector($selector);
let tag = match $tag {
Some(tag) => meta.query_fixed(tag, Rotation::cur()),
None => {
let tag = F::from(bit_len_tag[&$bit_lens[0]] as u64);
selector.clone() * Expression::Constant(tag)
},
};
let value = meta.query_advice($value, Rotation::cur());
vec![(tag, t_tag), (selector * value, t_value)]
});
)*
};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I try to avoid macros. But this one in particular is clear, easy to understand and with a really tiny scope. So it's fine at least for me to keep it as is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, feels like it could be replaced by a function or closure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to function in 0ca396e.

Comment thread transcript/src/transcript.rs Outdated
use std::marker::PhantomData;

/// `PointRepresentation` will encode point with an implemented strategy
/// TODO: Generalize `ecc_chip` with `EccInstrucitons`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we file an issue for this and remove the TODO?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already filed the issue. Feel free to just remove this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 0ca396e

@CPerezz

CPerezz commented Sep 9, 2022

Copy link
Copy Markdown
Contributor

Feel free to merge when all the checks pass @han0110 🎉

@CPerezz CPerezz merged commit e155f01 into privacy-ethereum:master Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use tagged table for RangeChip to reduce lookup

2 participants